/*

Hunt Allcott
Proposal title: The Marginal Internality

HYPOTHESES

Stated-Hyp 1: Consumers who receive the intervention are more likely to purchase CFLs after the intervention.

	Test-Hyp 1: Participants in the information intervention condition will be more likely to switch to CFL than participants in the information control condition.

Stated Hypothesis 2: Marginal internality could vary by price. 
	
	Unclear how to test. Proposal says "In each of the two sets of choices (one before and one after the intervention), there are three decisions, 	with three different levels of CFL rebate." However, it is not clear which three decisions are referred to.
	
********************************************************************************

NOTES: 
	
I had some trouble identifying which variables are the pre-and post-decisions. 
My understanding is that Q1 is the first time the question is asked. Based on 
the questionnaire (p. 31), Q5 is the second time this question is asked. It is 
unclear what Q1_initial is.
	
*/

clear all
use "Allcott339.dta", clear

********************************************************************************

* RECODING

* Experiment condition (see Table on page 3 of survey)
	tab xtess125, mis
	tab xtess125, nolabel
	recode xtess125 (1/4 = 1) (9/16 = 1) (nonmiss=0), gen(condition)
	lab def condition_Label 0 "0 Control" 1 "1 Treatment"
	lab val condition condition_Label 
	tab condition xtess125, mis

* DV - Pre (count the number of times participant chose the CFL bulb before the treatment)

	* Understand coding
	tab q1_decision_1, mis
	tab q1_decision_1, nolabel
	tab q1_decision_2, mis
	tab q1_decision_2, nolabel

	* Generate variable that indicates whether participant chose the CFL bulb
	gen cfl_choice_pre_1 = 0
	gen cfl_choice_pre_2 = 0
	gen cfl_choice_pre_3 = 0
	gen cfl_choice_pre_4 = 0
	gen cfl_choice_pre_5 = 0
	gen cfl_choice_pre_6 = 0
	gen cfl_choice_pre_7 = 0
	gen cfl_choice_pre_8 = 0
	gen cfl_choice_pre_9 = 0
	gen cfl_choice_pre_10 = 0
	gen cfl_choice_pre_11 = 0
	gen cfl_choice_pre_12 = 0
	gen cfl_choice_pre_13 = 0
	
	* Replace new variables with missing values if refused answer
	replace cfl_choice_pre_1 = . if q1_decision_1 == -1
	replace cfl_choice_pre_2 = . if q1_decision_2 == -1
	replace cfl_choice_pre_3 = . if q1_decision_3 == -1
	replace cfl_choice_pre_4 = . if q1_decision_4 == -1
	replace cfl_choice_pre_5 = . if q1_decision_5 == -1
	replace cfl_choice_pre_6 = . if q1_decision_6 == -1
	replace cfl_choice_pre_7 = . if q1_decision_7 == -1
	replace cfl_choice_pre_8 = . if q1_decision_8 == -1
	replace cfl_choice_pre_9 = . if q1_decision_9 == -1
	replace cfl_choice_pre_10 = . if q1_decision_10 == -1
	replace cfl_choice_pre_11 = . if q1_decision_11 == -1
	replace cfl_choice_pre_12 = . if q1_decision_12 == -1
	replace cfl_choice_pre_13 = . if q1_decision_13 == -1
	
	* Replace new variables with 1 if CFL bulb was chosen. Note that whether the CFL bulb was choice A (coded as 1) or choice B depended on 		participants condition.
	
	* In uneven (i.e., 1, 3, 5 etc.) conditions, choice A is the CFL bulb (see Table on page 8 in Survey)
	replace cfl_choice_pre_1 = 1 if q1_decision_1 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_2 = 1 if q1_decision_2 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_3 = 1 if q1_decision_3 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_4 = 1 if q1_decision_4 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_5 = 1 if q1_decision_5 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_6 = 1 if q1_decision_6 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_7 = 1 if q1_decision_7 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_8 = 1 if q1_decision_8 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_9 = 1 if q1_decision_9 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_10 = 1 if q1_decision_10 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_11 = 1 if q1_decision_11 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_12 = 1 if q1_decision_12 == 1 & mod(xtess125, 2) == 1
	replace cfl_choice_pre_13 = 1 if q1_decision_13 == 1 & mod(xtess125, 2) == 1

	* In even (i.e., 2, 4, 6 etc.) conditions, choice B is the CFL bulb (see Table on page 7 in Survey)
	replace cfl_choice_pre_1 = 1 if q1_decision_1 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_2 = 1 if q1_decision_2 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_3 = 1 if q1_decision_3 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_4 = 1 if q1_decision_4 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_5 = 1 if q1_decision_5 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_6 = 1 if q1_decision_6 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_7 = 1 if q1_decision_7 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_8 = 1 if q1_decision_8 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_9 = 1 if q1_decision_9 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_10 = 1 if q1_decision_10 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_11 = 1 if q1_decision_11 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_12 = 1 if q1_decision_12 == 2 & mod(xtess125, 2) == 0
	replace cfl_choice_pre_13 = 1 if q1_decision_13 == 2 & mod(xtess125, 2) == 0

	* Count number of times CFL bulb was chosen
	gen cfl_choices_pre = cfl_choice_pre_1 + cfl_choice_pre_2 + cfl_choice_pre_3 + cfl_choice_pre_4 + cfl_choice_pre_5 + cfl_choice_pre_6 + cfl_choice_pre_7 + cfl_choice_pre_8 + cfl_choice_pre_9 + cfl_choice_pre_10 + cfl_choice_pre_11 + cfl_choice_pre_12 + cfl_choice_pre_13
	tab cfl_choices_pre, mis
	
* DV - Post (count the number of times participant chose the CFL bulb after the treatment)

	* Understand coding
	tab q5_decision_14, mis
	tab q5_decision_14, nolabel
	tab q5_decision_15, mis
	tab q5_decision_15, nolabel

	* Generate variable that indicates whether participant chose the CFL bulb
	gen cfl_choice_post_1 = 0
	gen cfl_choice_post_2 = 0
	gen cfl_choice_post_3 = 0
	gen cfl_choice_post_4 = 0
	gen cfl_choice_post_5 = 0
	gen cfl_choice_post_6 = 0
	gen cfl_choice_post_7 = 0
	gen cfl_choice_post_8 = 0
	gen cfl_choice_post_9 = 0
	gen cfl_choice_post_10 = 0
	gen cfl_choice_post_11 = 0
	gen cfl_choice_post_12 = 0
	gen cfl_choice_post_13 = 0
	
	* Replace new variables with missing values if refused answer
	replace cfl_choice_post_1 = . if q5_decision_14 == -1
	replace cfl_choice_post_2 = . if q5_decision_15 == -1
	replace cfl_choice_post_3 = . if q5_decision_16 == -1
	replace cfl_choice_post_4 = . if q5_decision_17 == -1
	replace cfl_choice_post_5 = . if q5_decision_18 == -1
	replace cfl_choice_post_6 = . if q5_decision_19 == -1
	replace cfl_choice_post_7 = . if q5_decision_20 == -1
	replace cfl_choice_post_8 = . if q5_decision_21 == -1
	replace cfl_choice_post_9 = . if q5_decision_22 == -1
	replace cfl_choice_post_10 = . if q5_decision_23 == -1
	replace cfl_choice_post_11 = . if q5_decision_24 == -1
	replace cfl_choice_post_12 = . if q5_decision_25 == -1
	replace cfl_choice_post_13 = . if q5_decision_26 == -1
	
	* Replace new variables with 1 if CFL bulb was chosen. Note that whether the CFL bulb was choice A (coded as 1) or choice B depended on 		participants condition.
	
	* In uneven (i.e., 1, 3, 5 etc.) conditions, choice A is the CFL bulb (see Table on page 34-35 in Survey)
	replace cfl_choice_post_1 = 1 if q5_decision_14 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_2 = 1 if q5_decision_15 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_3 = 1 if q5_decision_16 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_4 = 1 if q5_decision_17 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_5 = 1 if q5_decision_18 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_6 = 1 if q5_decision_19 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_7 = 1 if q5_decision_20 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_8 = 1 if q5_decision_21 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_9 = 1 if q5_decision_22 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_10 = 1 if q5_decision_23 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_11 = 1 if q5_decision_24 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_12 = 1 if q5_decision_25 == 1 & mod(xtess125, 2) == 0
	replace cfl_choice_post_13 = 1 if q5_decision_26 == 1 & mod(xtess125, 2) == 0

	* In even (i.e., 2, 4, 6 etc.) conditions, choice B is the CFL bulb (see Table on page 34 in Survey)
	replace cfl_choice_post_1 = 1 if q5_decision_14 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_2 = 1 if q5_decision_15 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_3 = 1 if q5_decision_16 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_4 = 1 if q5_decision_17 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_5 = 1 if q5_decision_18 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_6 = 1 if q5_decision_19 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_7 = 1 if q5_decision_20 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_8 = 1 if q5_decision_21 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_9 = 1 if q5_decision_22 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_10 = 1 if q5_decision_23 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_11 = 1 if q5_decision_24 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_12 = 1 if q5_decision_25 == 2 & mod(xtess125, 2) == 1
	replace cfl_choice_post_13 = 1 if q5_decision_26 == 2 & mod(xtess125, 2) == 1

	* Count number of times CFL bulb was chosen
	gen cfl_choices_post = cfl_choice_post_1 + cfl_choice_post_2 + cfl_choice_post_3 + cfl_choice_post_4 + cfl_choice_post_5 + cfl_choice_post_6 + cfl_choice_post_7 + cfl_choice_post_8 + cfl_choice_post_9 + cfl_choice_post_10 + cfl_choice_post_11 + cfl_choice_post_12 + cfl_choice_post_13
	tab cfl_choices_post, mis
	
* DV: Difference-Score

	gen cfl_choices_diff = cfl_choices_post - cfl_choices_pre
	tab cfl_choices_diff, mis
	
********************************************************************************

* ANALYSIS

* Test-Hyp 1: Participants in the information intervention condition will be more likely to switch to CFL than participants in the information control condition.

	reg cfl_choices_diff i.condition
	// support for H1 (p = .016)
	tess 1.condition +, init(Allcott339)
